   $(function(){
	   $("#collapseOne").hide();
	   var basePath = $("#base").val();
	  function getsubmenus(id,secondId)
	  {
		    var rID = "#" +id+"";
		    var secondID = "#" + secondId + "";
			if($(rID).val()!=0)
			{
				 pmid=$(rID).val(); 
			  var uri =basePath + "backend/getsubmenus";
			  //alert(uri);
			  //不能要dataType=json，不然解析不出来。。。。
			  $.ajax({   
				  type: "POST",  
				  url: uri,  
				  data: 'pmid=' + pmid,  
				  timeout: 15*1000,
				  success: function(data){ 
					  alert(data+"----111");
					  
					  
					  
					  var second= "<option value='0'>---从菜单---</option>";
					  if(data!="")
					 {
						  var member=eval("("+data + ")"); //正确写法
						  for(var i=0;i<member.length;i++)
			               	{						 
			            	var test="<option value='"+member[i].id+"'>"+member[i].name+"</option>";
			            	second+=test; 	
			                }
				     }
				//	  alert(second);
					$(secondID).html(second);
				  },
				  error:function(result){
		              	alert("ASd");
		              }
			  });
	        }
	  }
	  function gettmenus(id,secondId)
	  {
		    var rID = "#" +id+"";
		    var secondID = "#" + secondId + "";
			if($(rID).val()!=0)
			{
			 sid=$(rID).val();
			 var uri =basePath + "backend/gettmenus" ;
			// alert(uri);
			  //不能要dataType=json，不然解析不出来。。。。
			  $.ajax({   
				  type: "POST",  
				  url: uri,  
				  data: 'sid=' + sid,  
				  timeout: 15*1000,
				  success: function(data){  
					  var member=eval("("+data + ")"); //正确写法
					  var second= "<option value='0'>---内容主题---</option>";
					  for(var i=0;i<member.length;i++)
		               	{						 
		            	var test="<option value='"+member[i].tId+"'>"+member[i].tName+"</option>";
		            	second+=test; 	
		               	}
					$(secondID).html(second);
				  },
				  error:function(result){
		              	alert("ASd");
		              }
			  });
	        }
	  }
	
	
	  $("#pmenu").change(function(){
		
		  getsubmenus("pmenu","smenu");
	  });
	   $("#smenu").change(function(){
		   gettmenus("smenu","tmenu");
	   });
	   $("#traderForm").validate({
		  rules:{
			  pmenu:{
				  required:true,
				  min:1
			  },smenu:{
				  required:true,
				  min:1
			  },tmenu:{
				  required:true,
				  min:1
			  }
		  },messages:{
			  pmenu:{
				  required:"必填",
				  min:"必填"
			  },smenu:{
				  required:"必填",
				  min:"必填"
			  },tmenu:{
				  required:"必填",
				  min:"必填"
			  }
		  },
			errorPlacement: function(error, element) {                             //错误信息位置设置方法  
				 error.appendTo( element.next("span") );                            //这里的element是录入数据的对象  
			 },
			 errorElement:"span" 
	   });
	  
		   var yearFrom=new Date().getYear()-50+1900;
		     var yearTo=new Date().getYear()+1900;   
		   $('#dateinput').datepicker({  
			    dateFormat: 'yy-mm-dd',  
			    buttonImage: '/TradeBook/images/calender.png',
			    buttonImageOnly: true,  
			    showOn: 'both',
			    yearRange: yearFrom+':'+yearTo,
			    clearText:'清除',
			    closeText:'关闭',
			    prevText:'前一月',
			    nextText:'后一月',
			    currentText:' ',
			    monthNamesShort:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
			    changeYear: true ,
			    changeMonth: true,
			    dateFormat: 'yy-mm-dd' ,
			    dayNamesMin: ['一', '二', '三', '四', '五', '六', '日']  ,
			    duration: 'slow'
			    }); 
	  
	   $("#getTraderMail").val($("#traderMail").html());
   });